<template>
	<view class="e-p-20">
		<view class="app-digit-detail bg-white e-radius-20" v-if="info">
			<view class="e-m-b-20 e-font-28" style="display: flex;">
				<view class="app-digit-detail__label c-999">
					{{$t('digitIntegral.交易hash')}}
				</view>
				<view class="e-flex-1 c-333 e-p-r-16">{{info.hash}}</view>
				<image :src="$staticPath('copy.png')" class="img-32" @tap="$copy(',,,')"></image>
			</view>
			<view class="e-m-b-20 e-font-28" style="display: flex;">
				<view class="app-digit-detail__label c-999">
					{{$t('digitIntegral.时间戳')}}
				</view>
				<view class="e-flex-1 c-333 e-p-r-16">{{info.createTime ? $timeFormat(info.createTime,'yyyy-mm-dd hh:MM:ss') : '-'}}</view>
			</view>
			<view class="e-m-b-20 e-font-28" style="display: flex;">
				<view class="app-digit-detail__label c-999">
					{{$t('digitIntegral.区块高度')}}
				</view>
				<view class="e-flex-1 c-333 e-p-r-16">{{info.transactionJSON.blockNumber}}</view>
			</view>
			<view class="e-m-b-20 e-font-28" style="display: flex;">
				<view class="app-digit-detail__label c-999">
					{{$t('digitIntegral.交易金额')}}
				</view>
				<view class="e-flex-1 c-333 e-p-r-16">{{info.transNumber}}</view>
			</view>
			<view class="e-m-b-20 e-font-28" style="display: flex;">
				<view class="app-digit-detail__label c-999">
					{{$t('digitIntegral.结果')}}
				</view>
				<view class="e-flex-1 c-333 e-p-r-16">
					<text v-if="info.status === 0">处理中</text>
					<text v-else-if="info.status === 1">交易成功</text>
					<text v-else-if="info.status === 2">交易失败</text>
				</view>
			</view>
			<view class="e-m-b-20 e-font-28" style="display: flex;">
				<view class="app-digit-detail__label c-999">
					{{$t('digitIntegral.交易内容')}}
				</view>
				<view class="e-flex-1 c-333 e-p-r-16" v-if="info.log">
					<view class="e-m-b-20">
						<view class="e-flex-1 e-p-r-20 e-m-b-30">
							<view class="c-999 e-font-28 e-m-b-10">
								发起地址
							</view>
							<view class="c-333 e-font-28">{{info.log.from.value}}</view>
						</view>
						<view class="e-flex-1">
							<view class="c-999 e-font-28 e-m-b-10">
								目标地址
							</view>
							<view class="c-333 e-font-28">{{info.log.to.value}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { ref } from 'vue'
	import { onLoad, onShow,onReachBottom } from '@dcloudio/uni-app';
	import {getTransactionDetails} from '@/common/request/api'
	import {
		useCurrentInstance,
		useQueryPage
	} from '@/common/hooks'
	
	const ctx = useCurrentInstance()
	const info = ref({})
	
	
	onLoad(opt => {
		if (opt.id) {
			getTransactionDetails({id:opt.id}).then(res => {
				res.data.transactionJSON = res.data.transactionJson ? JSON.parse(res.data.transactionJson) : {}
				if (res.data.transactionJSON.logs && res.data.transactionJSON.logs.length) {
					res.data.log = res.data.transactionJSON.logs[0]
				} else {
					res.data.log = ''
				}
				info.value = res.data
			})
		}
	})
</script>

<style lang="scss" scoped>
	@include appBem_b(digit-detail) {
		padding: 30rpx 20rpx;
		@include appBem_e(label) {
			flex: 0 0 150rpx;
		}
	}
</style>